package dxc02;

public class MyThread extends Thread {
    public MyThread() {
        super();
    }

    public MyThread(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println(getName() + "线程执行了" + i);
            Thread.yield();//表示出让当前cpu的执行权
            //每次多线程程序的执行是有随机性，谁强到cpu的执行权未知的
        }
    }
}
